package com.zmn.mcc.services.impl.staff.staffreinstatement;

import com.zmn.mcc.model.entity.staff.staffreinstatement.StaffReinstatement;
import com.zmn.mcc.persistence.interfaces.staff.staffreinstatement.StaffReinstatementDAO;
import com.zmn.mcc.services.interfaces.staff.staffreinstatement.StaffReinstatementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * 描述: 复职信息表基础接口实现类
 *
 * @author tanghongjun
 * @since 2020-10-22 15:53:17
 **/
@Slf4j
@Service
public class StaffReinstatementServiceImpl implements StaffReinstatementService {

    private static final String TAG = "复职信息表基础服务接口";

    @Resource
    private StaffReinstatementDAO staffReinstatementDao;

    /**
     * 描述: 根据id查询数据
     *
     * @param reinstateId id
     * @author tanghongjun
     * @since 2020-10-22 15:53:17
     **/
    @Override
    public StaffReinstatement findById(Integer reinstateId) {

        if (Objects.isNull(reinstateId)) {
            log.error("[{}],根据id查询数据reinstateId为null", TAG);
            return null;
        }
        return staffReinstatementDao.findById(reinstateId);
    }

    @Override
    public StaffReinstatement findByStaffId(Integer staffId) {
        if (Objects.isNull(staffId)) {
            log.error("[{}],根据staffId查询数据staffId为null", TAG);
            return null;
        }
        return staffReinstatementDao.findByStaffId(staffId);
    }

    /**
     * 描述: 根据id修改数据 id为必传
     *
     * @param staffReinstatement 待修改数据
     * @return java.lang.Integer
     * @author tanghongjun
     * @since 2020-10-22 15:53:17
     **/
    @Override
    public Integer updateByKey(StaffReinstatement staffReinstatement) {

        if (Objects.isNull(staffReinstatement.getReinstateId())) {
            log.error("[{}],根据id修改数据,staffReinstatement为null", TAG);
            return null;
        }
        return staffReinstatementDao.updateByKey(staffReinstatement);
    }

    /**
     * 描述: 新增数据
     *
     * @param staffReinstatement 待新增数据
     * @return java.lang.Integer 主键key
     * @author tanghongjun
     * @since 2020-10-22 15:53:17
     **/
    @Override
    public Integer insert(StaffReinstatement staffReinstatement) {

        if (Objects.isNull(staffReinstatement)) {
            log.error("[{}],新增数据,staffReinstatement为null", TAG);
            return null;
        }
        return staffReinstatementDao.insert(staffReinstatement);
    }

    /**
     * 描述: 根据主键删除数据
     *
     * @param reinstateId
     * @return: 执行结果码
     * @auther: tanghongjun
     * @since: 2020-10-22 15:53:17
     */
    @Override
    public Integer deleteByKey(Integer reinstateId) {

        if (Objects.isNull(reinstateId)) {
            log.error("[{}],根据id删除数据,reinstateId为null", TAG);
            return null;
        }
        return staffReinstatementDao.deleteByKey(reinstateId);
    }

}